/*
 * @Description: 状态管理
 * @Author: yiling (315800015@qq.com)
 * @Date: 2021-06-27 13:09:43
 * @LastEditors: yiling (315800015@qq.com)
 * @LastEditTime: 2021-07-12 13:45:35
 * @FilePath: \tm_uni_app\src\store\index.js
 */

// 此处为vuex全局
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

import user from './modules/user.js' // 此模块为用户登录状态模块
import hx from './modules/hx.js' // 此模块为用户登录状态模块
import tabBar from './tabBar' // 自定义底部tabBar

// 实例化vuex为store模块
const store = new Vuex.Store({
  strict: true,
  state: {
    allConfig: {}, // 全局配置信息
    location: {}, // 定位信息
    switchBusinessHall: {}, // 切换营业厅信息
    selectProduct: [], // 选中的商品，用于代客下单
  },
  modules: {
    user,
    tabBar,
	hx
  },
  getters: {
    ...tabBar.getters,
  },
  mutations: {
    setAllConfig(state, val) {
      console.log('state setAllConfig===', state, val, Date.now())
      state.allConfig = val
    },
    setLocation(state, val) {
      console.log('state location===', state, val, Date.now())
      state.location = val
    },
    setSwitchBusinessHall(state, val) {
      console.log('state switchBusinessHall===', state, val, Date.now())
      state.switchBusinessHall = val
    },
    setSelectProduct(state, val) {
      console.log('state selectProductId===', state, val, Date.now())
      state.selectProduct = val
    },
  },
})
console.log('store==', store)
export default store

